/**
 * COPYRIGHT HangZhou Trustway Technology Company Limited
 * All right reserved.
 */
package com.robam.cloud.authcenter.manager;

import com.robam.cloud.authcenter.helper.ThirdAuthGateway;
import com.robam.cloud.authcenter.helper.impl.AlipayAuthGateway;
import com.robam.cloud.authcenter.helper.impl.LjkjAuthGateway;
import com.robam.cloud.authcenter.helper.impl.WechatAuthGateway;
import com.robam.cloud.authcenter.helper.impl.ZwwAuthGateway;
import com.robam.cloud.common.bean.authcenter.enumspace.AuthPlatformTypeEnum;
import com.robam.cloud.common.bean.restful.entity.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author 薛铁琪
 * @CreateTime 2020-07-20 16:09
 * @Version 1.0
 */
@Component
public class ThirdAuthManager {
    @Autowired
    AlipayAuthGateway alipayAuthGateway;
    @Autowired
    WechatAuthGateway wechatAuthGateway;
    @Autowired
    ZwwAuthGateway zwwAuthGateway;
    @Autowired
    LjkjAuthGateway ljkjAuthGateway;

    public ThirdAuthGateway call(AuthPlatformTypeEnum authPlatformTypeEnum) {
        ThirdAuthGateway thirdAuthGateway = null;
        if (authPlatformTypeEnum == AuthPlatformTypeEnum.WECHAT) {
            thirdAuthGateway = wechatAuthGateway;
        } else if (authPlatformTypeEnum == AuthPlatformTypeEnum.ALIPAY) {
            thirdAuthGateway = alipayAuthGateway;
        } else if (authPlatformTypeEnum == AuthPlatformTypeEnum.ZWW) {
            thirdAuthGateway = zwwAuthGateway;
        } else if (authPlatformTypeEnum == AuthPlatformTypeEnum.LJKJ) {
            thirdAuthGateway = wechatAuthGateway;
        } else {
            throw new ServiceException("三方平台类型无法识别");
        }
        return thirdAuthGateway;
    }
}
